package com.example.Comparator;

import com.example.POJO.OrderView;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.List;

public class OrderViewComparator implements Comparator<OrderView> {

    @Override
    public int compare(OrderView orderView1, OrderView orderView2) {
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

        try {
            Date date1 = dateFormat.parse(orderView1.getTime());
            Date date2 = dateFormat.parse(orderView2.getTime());

            return date1.compareTo(date2);
        } catch (ParseException e) {
            e.printStackTrace();
            // Handle the exception according to your needs
            return 0;
        }
    }
}
